package net.csdra.libraryborrowing.service.book;

import net.csdra.libraryborrowing.domain.book.BookOrderLog;
import net.csdra.libraryborrowing.domain.book.BookOrderLogRepository;
import net.csdra.libraryborrowing.util.Utils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by xiaomi on 2017/10/17.
 */
@Component
public class BookOrderLogComponentImpl implements BookOrderLogComponent {

    @Autowired
    BookOrderLogRepository bookOrderLogRepository;

    @Override
    public BookOrderLog createBookOrderLog(CreateBookOrderLog createBookOrderLog) {
        BookOrderLog bookOrderLog = Utils.createAutoSet(BookOrderLog.class, null);
        Utils.copy(createBookOrderLog, bookOrderLog);
        bookOrderLogRepository.save(bookOrderLog);
        BookOrderLog returnValue = new BookOrderLog();
        BeanUtils.copyProperties(bookOrderLog, returnValue);
        return returnValue;
    }
}
